package org.hxzon.workeasy.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hxzon.workeasy.model.base.SimpleBelongToUser;

@Entity
//@Indexed
public class PostTag extends SimpleBelongToUser {

    private static final long serialVersionUID = 6705569910023553421L;

    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "tagId", referencedColumnName = "id", insertable = false, updatable = false)
    private EasyTag easyTag;

    @ManyToOne(fetch = FetchType.LAZY)
    @NotFound(action = NotFoundAction.IGNORE)
    @JoinColumn(name = "postId", referencedColumnName = "id", insertable = false, updatable = false)
    private EasyPost easyPost;

    @Column(length = DefineIdSize)
    private String tagId;

    @Column(length = DefineIdSize)
    private String postId;

    public EasyTag getEasyTag() {
        return easyTag;
    }

    public void setEasyTag(EasyTag easyTag) {
        this.easyTag = easyTag;
        if (easyTag != null) {
            this.tagId = easyTag.getId();
        } else {
            this.tagId = null;
        }
    }

    public EasyPost getEasyPost() {
        return easyPost;
    }

    public void setEasyPost(EasyPost easyPost) {
        this.easyPost = easyPost;
        if (easyPost != null) {
            this.postId = easyPost.getId();
        } else {
            this.postId = null;
        }
    }

    public String getTagId() {
        return tagId;
    }

    public void setTagId(String tagId) {
        this.tagId = tagId;
    }

    public String getPostId() {
        return postId;
    }

    public void setPostId(String postId) {
        this.postId = postId;
    }

}
